﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

public partial class DeliverGoodsManagement_DeliverGoods : System.Web.UI.Page
{
    private string Code
    {
        get
        {
            return Request.QueryString["Code"] != null ? Request.QueryString["Code"].ToString() : "";
        }
    }

    /// <summary>
    /// 订单明细
    /// </summary>
    private DataSet OrderDetails
    {
        get
        {
            DataSet dstOrderDetails = null;
            if (ViewState["OrderDetails"] != null)
            {
                dstOrderDetails = (DataSet)ViewState["OrderDetails"];
            }
            return dstOrderDetails;
        }
        set
        {
            ViewState["OrderDetails"] = value;
        }
    }

    private List<Model.SENDDOCDETAIL> InvoiceDetails
    {
        get
        {
            List<Model.SENDDOCDETAIL> invoiceDetails = null;
            if (ViewState["InvoiceDetails"] != null)
            {
                invoiceDetails = (List<Model.SENDDOCDETAIL>)ViewState["InvoiceDetails"];
            }
            return invoiceDetails;
        }
        set
        {
            ViewState["InvoiceDetails"] = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindDropProductsList();
        }
    }

    private void BindDropProductsList()
    {
        DataSet dst = new BLL.ORDERDETAIL().GetOrderDetail(this.Code);
        if (dst != null)
        {
            dropProductsList.Items.Clear();
            ListItem item;
            for (int i = 0; i < dst.Tables[0].Rows.Count; i++)
            {
                item = new ListItem();
                item.Text = dst.Tables[0].Rows[i]["SPMC"].ToString();
                item.Value = dst.Tables[0].Rows[i]["OD_CMDCODE"].ToString();
                dropProductsList.Items.Add(item);
            }
            dropProductsList.Items.Insert(0, "请选择商品");
        }
    }
    protected void dropProductsList_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.OrderDetails != null)
        {
            for (int i = 0; i < this.OrderDetails.Tables[0].Rows.Count; i++)
            {
                if (this.OrderDetails.Tables[0].Rows[i]["OD_CMDCODE"].ToString() == dropProductsList.SelectedValue)
                {
                    txtProductColor.Text = this.OrderDetails.Tables[0].Rows[i]["COLOR"].ToString();
                    txtProductSize.Text = this.OrderDetails.Tables[0].Rows[i]["SIZE"].ToString();
                    //lblMessage.Text = "已发货数量:" + String.Format("{0:0",this.OrderDetails.Tables[0].Rows[i]["SIZE"])+",该商品目前可用库存数量:"+;
                }
            }
        }
        else
        {
            Share.Alert(this.Page, "没有找到订单信息！");
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (this.InvoiceDetails != null)
        {
            //Model.SENDDOCDETAIL invoiceDetail = new Model.SENDDOCDETAIL();
            //invoiceDetail.
        }
        else
        {
            this.InvoiceDetails = new List<Model.SENDDOCDETAIL>();

        }
    }
    protected void btnDeliver_Click(object sender, EventArgs e)
    {

    }
}
